namespace JQuery.WebKit
{
    using System.ComponentModel;
    using System.Security.Permissions;
    using System.Web;
    using System.Web.UI;

    [TypeConverter(typeof(ExpandableObjectConverter)), AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
    public sealed class SortSettings : IStateManager
    {
        private bool _isTracking;
        private StateBag _viewState = new StateBag();

        void IStateManager.LoadViewState(object state)
        {
            if (state != null)
            {
                ((IStateManager) this.ViewState).LoadViewState(state);
            }
        }

        object IStateManager.SaveViewState()
        {
            return ((IStateManager) this.ViewState).SaveViewState();
        }

        void IStateManager.TrackViewState()
        {
            this._isTracking = true;
            ((IStateManager) this.ViewState).TrackViewState();
        }

        public override string ToString()
        {
            return string.Empty;
        }

        [Category("Behavior"), DefaultValue("The column (datafield) to be used as a default sorting column on initial page load."), NotifyParentProperty(true), Description("")]
        public string InitialSortColumn
        {
            get
            {
                if (this.ViewState["InitialSortColumn"] != null)
                {
                    return (string) this.ViewState["InitialSortColumn"];
                }
                return "";
            }
            set
            {
                this.ViewState["InitialSortColumn"] = value;
            }
        }

        [DefaultValue(0), Description("The sort direction to be used on initial page load. Worksonly if InitialSortColumn is set. Asc (ascending) by default."), NotifyParentProperty(true), Category("Behavior")]
        public SortDirection InitialSortDirection
        {
            get
            {
                if (this.ViewState["InitialSortDirection"] != null)
                {
                    return (SortDirection) this.ViewState["InitialSortDirection"];
                }
                return SortDirection.Asc;
            }
            set
            {
                this.ViewState["InitialSortDirection"] = value;
            }
        }

        [NotifyParentProperty(true), DefaultValue(0), Category("Behavior"), Description("Determines when the sorting action takes place. Default is ClickOnHeader")]
        public JQuery.WebKit.SortAction SortAction
        {
            get
            {
                object obj2 = this.ViewState["SortAction"];
                if (obj2 == null)
                {
                    return JQuery.WebKit.SortAction.ClickOnHeader;
                }
                return (JQuery.WebKit.SortAction) obj2;
            }
            set
            {
                this.ViewState["SortAction"] = value;
            }
        }

        [Category("Behavior"), NotifyParentProperty(true), Description("The visual appearance of sorting icons in the column header. Default is Vertical."), DefaultValue(0)]
        public JQuery.WebKit.SortIconsPosition SortIconsPosition
        {
            get
            {
                object obj2 = this.ViewState["SortIconsPosition"];
                if (obj2 == null)
                {
                    return JQuery.WebKit.SortIconsPosition.Vertical;
                }
                return (JQuery.WebKit.SortIconsPosition) obj2;
            }
            set
            {
                this.ViewState["SortIconsPosition"] = value;
            }
        }

        bool IStateManager.IsTrackingViewState
        {
            get
            {
                return this._isTracking;
            }
        }

        private StateBag ViewState
        {
            get
            {
                return this._viewState;
            }
        }
    }
}

